package com.fire.center.controller;

import com.fire.center.domain.User;
import com.fire.center.service.UserService;
import com.fire.common.controller.BaseController;
import com.fire.common.core.page.TableDataInfo;
import com.fire.common.domain.Result;
import com.fire.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;


@RestController
public class UserController extends BaseController {

    @Autowired
    private UserService userService;

    /*
     * 条件分页查询
     * */
    @RequestMapping("/user/selectByConditions")
    public TableDataInfo shopList(@RequestBody User user) {
        startPage();
        List<User> list = userService.findByConditions(user);
        return getDataTable(list);
    }

    /*
     * 用户更新
     * */
    @RequestMapping("/user/updateUser")
    public Result updateUser(User user) {
        Result result = userService.updateUser(user);
        return result;
    }

    /*
     * 添加用户
     * */
    @RequestMapping("/user/insertUser")
    public Result insertUser(User user) {
        user.setId(IdUtils.randomUUID());
        Result result=userService.insertUser(user);
        return result;

    }

    /*
     * 删除用户
     * */
    @RequestMapping("/user/deleteUserById")
    public Result deleteUserById(String id) {
        Result result = userService.deleteUserById(id);
        return result;

    }
}
